//校验是否选择了电话号码
function checkoutPhoneNum() {
	var selectedPhoneNum = $("#selectPhoneNum").html();
	if(selectedPhoneNum == "请选择号码") {
		alert("请先选择号码");
		return;
	}else{
		var productId = $("#hidden_productId").val();
		window.location.href = "productChoosePackage.jhtml?selectedPhoneNum=" + selectedPhoneNum + "&productId="+ productId +"";
	}
}

//全局变量判机主姓名是否为空、身份证号是否为空及格式是否正确
var hostNameFlag = false;
var cardIdFlag = false;

//校验机主姓名和身份证号
function checkoutHostName(){
	if($("#hostName").val() == ""){
		alert("请填写机主姓名！");
		hostNameFlag = false;
		return;
	}else{
		hostNameFlag = true;
	}
}
function checkoutCartId(){
	var regx = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
	var cardId = $("#cardId").val();
	if(cardId == ""){
		alert("请填写身份证号!");
		cardIdFlag = false;
		return;
	}else if(!regx.test(cardId)) {
		alert("请输入正确身份证号!");
		cardIdFlag = false;
		return;
	}else{
		cardIdFlag = true;
	}
}

//点击去结算事件
function submitPhoneNumAndPhonePackage() {
	if(!hostNameFlag) {
		alert("机主姓名不能为空！");
		return;
	}else if(!cardIdFlag){
		alert("请输入正确身份证号!");
		return;
	}else{
		$("#hidden_hostName").attr("value", $("#hostName").val());
		$("#hidden_cardId").attr("value", $("#cardId").val());
		
		$("#submitForm").attr("action","${base}/weixin/member/order/submitProductAndPhoneNumInfo.jhtml");
		$("#submitForm").submit();
	}
}